<script setup lang="ts">
import Flex from "@/components/Layout/Flex.vue";
import type { Hot } from "../hooks/useHot";

interface Props {
  type?: string;
  list?: Array<Hot>;
  height?: number;
}
// props
const props = withDefaults(defineProps<Props>(), {
  type: "",
  list: () => []
});
// emit
const emit = defineEmits(["exchange", "select"]);
</script>

<template>
  <view class="hot">
    <Flex justify="space-between">
      <view class="title">热门问题</view>
      <Flex class="exchange" @click="emit('exchange')">
        <image src="@/static/Sync.png" />
        换一换
      </Flex>
    </Flex>
    <view class="list">
      <view
        class="item"
        v-for="(item, index) in props.list"
        :key="index"
        @click="emit('select', item.content)"
      >
        <view>
          <image class="icon-hot" src="@/static/hot.png"></image>
          <text class="text">{{ item.content }}</text>
        </view>
        <text class="gz">{{ item.hot_index }}关注</text>
      </view>
    </view>
  </view>
</template>

<style lang="scss" scoped>
.list {
  font-size: 12px;
  margin-top: 12px;
  .item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    background-color: var(--bg-hot-item);
    border-radius: 10px;
    border: 1px solid #1d545e;
    color: var(--color-text-default);
    &:not(:last-child) {
      margin-bottom: 8px;
    }
  }
  .icon-hot {
    display: inline-block;
    width: 12px;
    height: 12px;
    vertical-align: middle;
  }
  .text {
    display: inline-block;
    width: 205px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    vertical-align: middle;
    margin-left: 4px;
  }
  .gz {
    color: var(--color-text-assist-1);
  }
}
.hot {
  position: relative;
  width: 100%;
  height: 172px;
  border-radius: 10px;
  background: var(--bg-hot);
  margin: 0 auto 15px;
  box-sizing: border-box;
  padding: 16px;
  overflow: hidden;
}
.title {
  color: var(--color-text-default);
  font-size: 16px;
  font-weight: 500;
}
.exchange {
  font-size: 12px;
  color: var(--color-text-hight);
  image {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 3px;
  }
}
</style>
